﻿using System.IO;
using System.Windows;

using GalaSoft.MvvmLight.Ioc;

using HandyControl.Tools;

using Stock.Core;
using Stock.Service;
using Stock.ViewModel;

namespace Stock
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        private string[] args;
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            args = e.Args;

            Register();
        }

        private void Register()
        {
            SimpleIoc.Default.Register<AppService>();
            SimpleIoc.Default.Register<EasyMoneyService>();
            SimpleIoc.Default.Register<AppConfigService>();

            SimpleIoc.Default.Register<MainViewModel>();
            SimpleIoc.Default.Register<AddStockViewModel>();
            SimpleIoc.Default.Register<StockTrendViewModel>();
            SimpleIoc.Default.Register<StockDetailViewModel>();
            SimpleIoc.Default.Register<StockSpriteViewModel>();
            SimpleIoc.Default.Register<AppConfigViewModel>();

            var appService = SimpleIoc.Default.GetInstance<AppConfigService>();
            var configModel = appService.GetConfigModel();
            SimpleIoc.Default.Register(() => configModel);

            this.SetSkin(configModel.SkinType);
            this.SetColor(configModel);

            ConfigHelper.Instance.SetWindowDefaultStyle();
            ConfigHelper.Instance.SetNavigationWindowDefaultStyle();
        }

        public string[] GetArgs()
        {
            return args;
        }
    }
}
